
package com.lsw.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.lsw.R;
import com.lsw.view.RoundProgressBar;


/**
 * 加载状态
 *
 * @author lsw
 */
public class DialogProgressShowSpeed extends Dialog {

    private View.OnClickListener listener;

    public DialogProgressShowSpeed(Context context, View.OnClickListener listener) {
        super(context, R.style.DialogProgress);
        this.listener = listener;
    }

    private RoundProgressBar roundProgressBar;
    private TextView tv_canle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_progress_show_speed);
        roundProgressBar = (RoundProgressBar) findViewById(R.id.roundProgressBar);
        tv_canle = (TextView) findViewById(R.id.tv_canle);
        if (listener != null) {
            tv_canle.setOnClickListener(listener);
        } else {
            tv_canle.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dismiss();
                }
            });
        }
        Window windowDia = this.getWindow();
        WindowManager.LayoutParams lp = windowDia.getAttributes();
        lp.gravity = Gravity.CENTER;
        windowDia.setAttributes(lp);
        setCanceledOnTouchOutside(false);
    }

    public void setProgressBar(int Progress) {
        roundProgressBar.setProgress(Progress);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
    }
}
